﻿@model OrderTotalsModel
@using Nop.Web.Models.ShoppingCart;
<div class="cart-ordertotal-module">
    <div class="title">Order Totals</div>
    <div class="body">
        <div class="item">
            <div class="name">@T("ShoppingCart.Totals.SubTotal"):</div>
            <div class="value">
                <span class="amount">@Model.SubTotal</span>
            </div>
        </div>
        @if (!String.IsNullOrEmpty(Model.SubTotalDiscount))
        {

            <div class="item">
                <div class="name">@T("ShoppingCart.Totals.SubTotalDiscount"):</div>
                <div class="value">
                    @if (Model.AllowRemovingSubTotalDiscount)
                    {
                        /*empty value (little hack for FormValueExistsAttribute)*/
                        <div class="button-wrap">
                            <input type="submit" name="removesubtotaldiscount" value="@Model.SubTotalDiscount - @T("Common.Remove")" title="@T("Common.Remove") discount @Model.SubTotalDiscount" class="btn btn-default btn-xs remove-discount-button" />
                        </div>
                    }
                    else
                    {
                        <span class="amount">@Model.SubTotalDiscount</span>
                    }
                </div>
            </div>
        }
        <div class="item">
            <div class="name">@T("ShoppingCart.Totals.Shipping"):</div>
            <div class="value">
                @if (Model.RequiresShipping && !String.IsNullOrEmpty(Model.SelectedShippingMethod))
                {
                    <span class="selected-shipping-method">
                        @T("ShoppingCart.Totals.Shipping.Method", Model.SelectedShippingMethod)
                    </span>
                }
                @if (Model.RequiresShipping)
                {
                    if (!String.IsNullOrEmpty(Model.Shipping))
                    {
                        <span class="amount">
                            @Model.Shipping
                        </span>
                    }
                    else
                    {
                        <span>@T("ShoppingCart.Totals.CalculatedDuringCheckout")</span>
                    }
                }
                else
                {
                    <span>@T("ShoppingCart.Totals.Shipping.NotRequired")</span>
                }
            </div>
        </div>

        @if (!String.IsNullOrEmpty(Model.PaymentMethodAdditionalFee))
        {

            <div class="item">
                <div class="name">@T("ShoppingCart.Totals.PaymentMethodAdditionalFee"):</div>
                <div class="value">
                    <span class="amount">@Model.PaymentMethodAdditionalFee</span>
                </div>
            </div>

        }
        @if (Model.DisplayTaxRates && Model.TaxRates.Count > 0)
        {
            foreach (var taxRate in Model.TaxRates)
            {

                <div class="item">
                    <div class="name">@string.Format(T("ShoppingCart.Totals.TaxRateLine").Text, taxRate.Rate):</div>
                    <div class="value">
                        <span class="amount">@taxRate.Value</span>
                    </div>
                </div>

            }
        }
        @if (Model.DisplayTax)
        {

            <div class="item">
                <div class="name">@T("ShoppingCart.Totals.Tax"): </div>
                <div class="value">
                    <span class="amount">@Model.Tax</span>
                </div>
            </div>

        }
        @if (!String.IsNullOrEmpty(Model.OrderTotalDiscount))
        {

            <div class="item">
                <div class="name">
                    @T("ShoppingCart.Totals.OrderTotalDiscount"):
                </div>
                <div class="value">
                    @if (Model.AllowRemovingOrderTotalDiscount)
                    {
                        <div class="button-wrap">
                            @*empty value (little hack for FormValueExistsAttribute)*@
                            <input type="submit" name="removeordertotaldiscount" value="@Model.OrderTotalDiscount - @T(" common.remove")" title="@T("Common.Remove") order total discount @Model.OrderTotalDiscount" class="btn btn-default btn-xs remove-discount-button" />
                        </div>
                    }
                    else
                    {
                        <span class="amount">@Model.OrderTotalDiscount</span>
                    }
                </div>
            </div>

        }
        @if (Model.GiftCards.Count > 0)
        {
            foreach (var gc in Model.GiftCards)
            {

                <div class="item gift-card">
                    <div class="name">
                        @if (Model.IsEditable)
                        { 
                            @*little hack here with empty "value" element*@
                            <input type="submit" name="removegiftcard-@gc.Id" value="@T("ShoppingCart.Totals.GiftCardInfo", gc.CouponCode) - @T("Common.Remove")" title="@T("Common.Remove") giftcard @T("ShoppingCart.Totals.GiftCardInfo", gc.CouponCode)" class="btn btn-default btn-xs remove-gift-card-button" />
                        }
                        else
                        {
                            @T("ShoppingCart.Totals.GiftCardInfo", gc.CouponCode)
                        }
                    </div>
                    <div class="new-line">
                        <div class="value">
                            <span class="amount">@gc.Amount</span>
                        </div>
                        <div class="remaining">
                            @string.Format(T("ShoppingCart.Totals.GiftCardInfo.Remaining").Text, gc.Remaining)
                        </div>
                    </div>
                </div>

            }
        }
        @if (Model.RedeemedRewardPoints > 0)
        {

            <div class="item">
                <div class="name">
                    @string.Format(T("ShoppingCart.Totals.RewardPoints").Text, Model.RedeemedRewardPoints):
                </div>

                <div class="value">
                    <span class="amount">@Model.RedeemedRewardPointsAmount</span>
                </div>
            </div>

        }

        <div class="item">
            <div class="name">
                @T("ShoppingCart.Totals.OrderTotal"):
            </div>
            <div class="value">
                @if (!String.IsNullOrEmpty(Model.OrderTotal))
                {
                    <span class="saving order-total"><strong>@Model.OrderTotal</strong></span>
                }
                else
                {
                    <span>@T("ShoppingCart.Totals.CalculatedDuringCheckout")</span>
                }
            </div>
        </div>
        @if (Model.WillEarnRewardPoints > 0)
        {
            <div class="item">
                <div class="name">
                    @T("ShoppingCart.Totals.RewardPoints.WillEarn"):
                </div>
                <div class="value">
                    <span class="amount">@string.Format(T("ShoppingCart.Totals.RewardPoints.WillEarn.Point").Text, Model.WillEarnRewardPoints)</span>
                </div>
            </div>
        }
    </div>

</div>
